package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	Name  string  `gorm:"type:varchar(20);not null;comment:商品名称"`
	Price float64 `gorm:"type:decimal(10,2);not null;comment:价格"`
	Stock int     `gorm:"type:int(5);not null;comment:库存数量"`
	Cover string  `gorm:"varchar(255);not null;comment:封面"`
	Intro string  `gorm:"varchar(35);not null;comment:描述"`
}

func (g *Goods) Add() error {
	return DB.Create(&g).Error
}

func (g *Goods) GetGoodsId(goodsId int) error {
	return DB.Where("id = ?", goodsId).First(&g).Error
}
